package operation;

import staff.Staff;
import staff.StaffList;
import java.util.Scanner;
public class ModifyOperation implements IOperation{
    @Override
    public Staff work(StaffList staffList) {
        System.out.println("员工基本信息修改");
        System.out.println("输入要修改的姓名");
        Scanner sc = new Scanner(System.in);
        Scanner sc1 = new Scanner(System.in);
        String staff_name = sc.nextLine();
        int size = staffList.getUsedSize();
        for (int i = 0; i < size; i++) {
            Staff staff = staffList.getStaffs(i);
            if(staff.getStaff_name().equals(staff_name)){
                System.out.println("输入修改后的编号");
                int newStaff_id = sc.nextInt();
                staff.setStaff_id(newStaff_id);
                System.out.println("输入修改后的姓名");
                String newStaff_name = sc1.nextLine();
                staff.setStaff_name(newStaff_name);
                System.out.println("输入修改后的性别");
                String newSex = sc1.nextLine();
                staff.setSex(newSex);
                System.out.println("输入修改后的生日");
                int newBirth = sc.nextInt();
                staff.setBirth(newBirth);
                System.out.println("输入修改后的部门代码");
                int newDepartment_id = sc.nextInt();
                staff.setDepartment_id(newDepartment_id);
                System.out.println("输入修改后的部门名称");
                String newDepartment_name = sc1.nextLine();
                staff.setDepartment_name(newDepartment_name);
                System.out.println("已修改成功！");
                return staff;
            }
        }
        System.out.println("输入有误！无此员工！");
        return null;
    }
}
